package com.edu.system.service.impl;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import com.edu.common.utils.DateUtils;
import com.edu.common.utils.ListUtils;
import com.edu.system.domain.StudentClassExt;
import com.edu.system.domain.TClass;
import com.edu.system.domain.TClassGroup;
import com.edu.system.domain.THighlights;
import com.edu.system.domain.TNotice;
import com.edu.system.domain.TPublishClass;
import com.edu.system.domain.req.PublishDTO;
import com.edu.system.mapper.StudentClassExtMapper;
import com.edu.system.mapper.TPublishClassMapper;
import com.edu.system.service.ITClassGroupService;
import com.edu.system.service.ITClassService;
import com.edu.system.service.ITHighlightsService;
import com.edu.system.service.ITNoticeService;
import com.edu.system.service.ITPublishClassService;
import com.edu.system.service.StudentClassExtService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 发布-班级关系Service业务层处理
 * 
 * @author xxxx
 * @date 2023-12-27
 */
@Service
public class StudentClassExtServiceImpl implements StudentClassExtService
{
    @Resource
    private StudentClassExtMapper studentClassExtMapper;


  @Override
  public StudentClassExt selectByEid(String eid) {
    return studentClassExtMapper.selectByEid(eid);
  }

  @Override
    public List<String> selectClassCodeByEid(String eid) {
        return Optional.ofNullable(studentClassExtMapper.selectByEid(eid))
            .map(a -> {
                List<String> l1 = Arrays.asList(a.getQualifiedClass().split(","));
                List<String> l2 = Arrays.asList(a.getTeachingClass().split(","));
                List<String> l3 = Arrays.asList(a.getElectiveClass().split(","));
                List<String> list = new ArrayList<>();
                list.addAll(l1);
                list.addAll(l2);
                list.addAll(l3);
                return list;
            })
            .orElseGet(ArrayList::new);
    }

    @Override
    public void batchInsert(List<StudentClassExt> lists) {
        studentClassExtMapper.batchInsertExt(lists);
    }

    @Override
    public StudentClassExt updateById(StudentClassExt ext){
      studentClassExtMapper.updateExt(ext);
      return ext;
    }
}
